home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / lsdvizint.lha / Noise.INC < prev    next >
Encoding:
Text File  |  1990-06-23  |  6.6 KB  |  447 lines

  1.  
  2. ******************************
  3. * Noise Tracker V1.00 Player *
  4. ******************************
  5.  
  6. Start_Muzak:
  7.     lea    Music,a0
  8.     add.l    #$03b8,a0
  9.     moveq    #$7f,d0
  10.     moveq    #0,d1
  11. Start_Muzak1:
  12.     move.l    d1,d2
  13.     subq.w    #1,d0
  14. Start_Muzak2:
  15.     move.b    (a0)+,d1
  16.     cmp.b    d2,d1
  17.     bgt.s    Start_Muzak1
  18.     dbf    d0,Start_Muzak2
  19.     addq.b    #1,d2
  20.  
  21. Start_Muzak3:
  22.     lea    Music,a0
  23.     lea    mt_sample1(pc),a1
  24.     asl.l    #8,d2
  25.     asl.l    #2,d2
  26.     add.l    #$438,d2
  27.     add.l    a0,d2
  28.     moveq    #$1e,d0
  29. Start_Muzak4:
  30.     move.l    d2,(a1)+
  31.     moveq    #0,d1
  32.     move.w    42(a0),d1
  33.     asl.l    #1,d1
  34.     add.l    d1,d2
  35.     add.l    #$1e,a0
  36.     dbf    d0,Start_Muzak4
  37.  
  38.     lea    mt_sample1(PC),a0
  39.     moveq    #0,d0
  40. mt_clear:
  41.     move.l    (a0,d0.w),a1
  42.     clr.l    (a1)
  43.     addq.w    #4,d0
  44.     cmp.w    #$7c,d0
  45.     bne.s    mt_clear
  46.  
  47.     clr.w    $dff0a8
  48.     clr.w    $dff0b8
  49.     clr.w    $dff0c8
  50.     clr.w    $dff0d8
  51.     clr.l    mt_partnrplay
  52.     clr.l    mt_partnote
  53.     clr.l    mt_partpoint
  54.  
  55.     move.b    Music+$3b6,mt_maxpart+1
  56.     rts
  57.  
  58. ; call 'Stop_Muzak' to switch the sound off
  59.  
  60. Stop_Muzak:
  61.     clr.w    $dff0a8
  62.     clr.w    $dff0b8
  63.     clr.w    $dff0c8
  64.     clr.w    $dff0d8
  65.     move.w    #$f,$dff096
  66.     rts
  67.  
  68. ; the playroutine - call this every frame
  69.  
  70. Replay_Muzak:
  71.     addq.w    #1,mt_counter
  72. mt_cool:
  73.     cmp.w    #6,mt_counter
  74.     bne.s    mt_notsix
  75.     clr.w    mt_counter
  76.     bra    mt_rout2
  77.  
  78. mt_notsix:
  79.     lea    mt_aud1temp(PC),a6
  80.     tst.b    3(a6)
  81.     beq.s    mt_arp1
  82.     lea    $dff0a0,a5        
  83.     bsr.s    mt_arprout
  84. mt_arp1:
  85.     lea    mt_aud2temp(PC),a6
  86.     tst.b    3(a6)
  87.     beq.s    mt_arp2
  88.     lea    $dff0b0,a5
  89.     bsr.s    mt_arprout
  90. mt_arp2:
  91.     lea    mt_aud3temp(PC),a6
  92.     tst.b    3(a6)
  93.     beq.s    mt_arp3
  94.     lea    $dff0c0,a5
  95.     bsr.s    mt_arprout
  96. mt_arp3:
  97.     lea    mt_aud4temp(PC),a6
  98.     tst.b    3(a6)
  99.     beq.s    mt_arp4
  100.     lea    $dff0d0,a5
  101.     bra.s    mt_arprout
  102. mt_arp4:
  103.     rts
  104.  
  105. mt_arprout:
  106.     move.b    2(a6),d0
  107.     and.b    #$0f,d0
  108.     tst.b    d0
  109.     beq    mt_arpegrt
  110.     cmp.b    #$01,d0
  111.     beq.s    mt_portup
  112.     cmp.b    #$02,d0
  113.     beq.s    mt_portdwn
  114.     cmp.b    #$0a,d0
  115.     beq.s    mt_volslide
  116.     rts
  117.  
  118. mt_portup:
  119.     moveq    #0,d0
  120.     move.b    3(a6),d0
  121.     sub.w    d0,22(a6)
  122.     cmp.w    #$71,22(a6)
  123.     bpl.s    mt_ok1
  124.     move.w    #$71,22(a6)
  125. mt_ok1:
  126.     move.w    22(a6),6(a5)
  127.     rts
  128.  
  129. mt_portdwn:
  130.     moveq    #0,d0
  131.     move.b    3(a6),d0
  132.     add.w    d0,22(a6)
  133.     cmp.w    #$538,22(a6)
  134.     bmi.s    mt_ok2
  135.     move.w    #$538,22(a6)
  136. mt_ok2:
  137.     move.w    22(a6),6(a5)
  138.     rts
  139.  
  140. mt_volslide:
  141.     moveq    #0,d0
  142.     move.b    3(a6),d0
  143.     lsr.b    #4,d0
  144.     tst.b    d0
  145.     beq.s    mt_voldwn
  146.     add.w    d0,18(a6)
  147.     cmp.w    #64,18(a6)
  148.     bmi.s    mt_ok3
  149.     move.w    #64,18(a6)
  150. mt_ok3:
  151.     move.w    18(a6),8(a5)
  152.     rts
  153. mt_voldwn:
  154.     moveq    #0,d0
  155.     move.b    3(a6),d0
  156.     and.b    #$0f,d0
  157.     sub.w    d0,18(a6)
  158.     bpl.s    mt_ok4
  159.     clr.w    18(a6)
  160. mt_ok4:
  161.     move.w    18(a6),8(a5)
  162.     rts
  163.  
  164. mt_arpegrt:
  165.     move.w    mt_counter(PC),d0
  166.     cmp.w    #1,d0
  167.     beq.s    mt_loop2
  168.     cmp.w    #2,d0
  169.     beq.s    mt_loop3
  170.     cmp.w    #3,d0
  171.     beq.s    mt_loop4
  172.     cmp.w    #4,d0
  173.     beq.s    mt_loop2
  174.     cmp.w    #5,d0
  175.     beq.s    mt_loop3
  176.     rts
  177.  
  178. mt_loop2:
  179.     moveq    #0,d0
  180.     move.b    3(a6),d0
  181.     lsr.b    #4,d0
  182.     bra.s    mt_cont
  183. mt_loop3:
  184.     moveq    #$00,d0
  185.     move.b    3(a6),d0
  186.     and.b    #$0f,d0
  187.     bra.s    mt_cont
  188. mt_loop4:
  189.     move.w    16(a6),d2
  190.     bra.s    mt_endpart
  191. mt_cont:
  192.     add.w    d0,d0
  193.     moveq    #0,d1
  194.     move.w    16(a6),d1
  195.     and.w    #$fff,d1
  196.     lea    mt_arpeggio(PC),a0
  197. mt_loop5:
  198.     move.w    (a0,d0),d2
  199.     cmp.w    (a0),d1
  200.     beq.s    mt_endpart
  201.     addq.l    #2,a0
  202.     bra.s    mt_loop5
  203. mt_endpart:
  204.     move.w    d2,6(a5)
  205.     rts
  206.  
  207. mt_rout2:
  208.     lea    Music,a0
  209.     move.l    a0,a3
  210.     add.l    #$0c,a3
  211.     move.l    a0,a2
  212.     add.l    #$3b8,a2
  213.     add.l    #$43c,a0
  214.     move.l    mt_partnrplay(PC),d0
  215.     moveq    #0,d1
  216.     move.b    (a2,d0),d1
  217.     asl.l    #8,d1
  218.     asl.l    #2,d1
  219.     add.l    mt_partnote(PC),d1
  220.     move.l    d1,mt_partpoint
  221.     clr.w    mt_dmacon
  222.  
  223.     lea    $dff0a0,a5
  224.     lea    mt_aud1temp(PC),a6
  225.     bsr    mt_playit
  226.     lea    $dff0b0,a5
  227.     lea    mt_aud2temp(PC),a6
  228.     bsr    mt_playit
  229.     lea    $dff0c0,a5
  230.     lea    mt_aud3temp(PC),a6
  231.     bsr    mt_playit
  232.     lea    $dff0d0,a5
  233.     lea    mt_aud4temp(PC),a6
  234.     bsr    mt_playit
  235.     move.w    #$01f4,d0
  236. mt_rls:
  237.     dbf    d0,mt_rls
  238.  
  239.     move.w    #$8000,d0
  240.     or.w    mt_dmacon,d0
  241.     move.w    d0,$dff096
  242.  
  243.     lea    mt_aud4temp(PC),a6
  244.     cmp.w    #1,14(a6)
  245.     bne.s    mt_voice3
  246.     move.l    10(a6),$dff0d0
  247.  
  248.  
  249.     move.w    #1,$dff0d4
  250. mt_voice3:
  251.     lea    mt_aud3temp(PC),a6
  252.     cmp.w    #1,14(a6)
  253.     bne.s    mt_voice2
  254.     move.l    10(a6),$dff0c0
  255.  
  256.     move.w    #1,$dff0c4
  257. mt_voice2:
  258.     lea    mt_aud2temp(PC),a6
  259.     cmp.w    #1,14(a6)
  260.     bne.s    mt_voice1
  261.     move.l    10(a6),$dff0b0
  262.  
  263.     move.w    #1,$dff0b4
  264. mt_voice1:
  265.     lea    mt_aud1temp(PC),a6
  266.     cmp.w    #1,14(a6)
  267.     bne.s    mt_voice0
  268.     move.l    10(a6),$dff0a0
  269.  
  270.     move.w    #1,$dff0a4
  271. mt_voice0:
  272.     move.l    mt_partnote(PC),d0
  273.     add.l    #$10,d0
  274.     move.l    d0,mt_partnote
  275.     cmp.l    #$400,d0
  276.     bne.s    mt_stop
  277. mt_higher:
  278.     clr.l    mt_partnote
  279.     addq.l    #1,mt_partnrplay
  280.     moveq    #0,d0
  281.     move.w    mt_maxpart(PC),d0
  282.     move.l    mt_partnrplay(PC),d1
  283.     cmp.l    d0,d1
  284.     bne.s    mt_stop
  285.     clr.l    mt_partnrplay
  286. ;    st    Pflag
  287. mt_stop:
  288.     tst.w    mt_status
  289.     beq.s    mt_stop2
  290.     clr.w    mt_status
  291.     bra.s    mt_higher
  292. mt_stop2:
  293.     rts
  294.  
  295. mt_playit:
  296.     move.l    (a0,d1.l),(a6)
  297.     addq.l    #4,d1
  298.     moveq    #0,d2
  299.     move.b    2(a6),d2
  300.     and.b    #$f0,d2
  301.     lsr.b    #4,d2
  302.  
  303.     move.b    (a6),d0
  304.     and.b    #$f0,d0
  305.     or.b    d0,d2
  306.     tst.b    d2
  307.     beq.s    mt_nosamplechange
  308.  
  309.     moveq    #0,d3
  310.     lea    mt_samples(PC),a1
  311.     move.l    d2,d4
  312.     asl.l    #2,d2
  313.     mulu    #$1e,d4
  314.     move.l    (a1,d2),4(a6)
  315.     move.w    (a3,d4.l),8(a6)
  316.     move.w    2(a3,d4.l),18(a6)
  317.     move.w    4(a3,d4.l),d3
  318.     tst.w    d3
  319.     beq.s    mt_displace
  320.     move.l    4(a6),d2
  321.     add.l    d3,d2
  322.     move.l    d2,4(a6)
  323.     move.l    d2,10(a6)
  324.     move.w    6(a3,d4.l),8(a6)
  325.     move.w    6(a3,d4.l),14(a6)
  326.     move.w    18(a6),8(a5)
  327.     bra.s    mt_nosamplechange
  328.  
  329. mt_displace:
  330.     move.l    4(a6),d2
  331.     add.l    d3,d2
  332.     move.l    d2,10(a6)
  333.     move.w    6(a3,d4.l),14(a6)
  334.     move.w    18(a6),8(a5)
  335. mt_nosamplechange:
  336.     move.w    (a6),d0
  337.     and.w    #$fff,d0
  338.     tst.w    d0
  339.     beq.s    mt_retrout
  340.     move.w    (a6),16(a6)
  341.     move.w    20(a6),$dff096
  342.     move.l    4(a6),(a5)
  343.     move.w    8(a6),4(a5)
  344.     move.w    (a6),d0
  345.     and.w    #$fff,d0
  346.     move.w    d0,6(a5)
  347.     move.w    20(a6),d0
  348.     or.w    d0,mt_dmacon
  349.  
  350. mt_retrout:
  351.     tst.w    (a6)
  352.     beq.s    mt_nonewper
  353.     move.w    (a6),22(a6)
  354.  
  355. mt_nonewper:
  356.     move.b    2(a6),d0
  357.     and.b    #$0f,d0
  358.     cmp.b    #$0b,d0
  359.     beq.s    mt_posjmp
  360.     cmp.b    #$0c,d0
  361.     beq.s    mt_setvol
  362.     cmp.b    #$0d,d0
  363.     beq.s    mt_break
  364.     cmp.b    #$0e,d0
  365.     beq.s    mt_setfil
  366.     cmp.b    #$0f,d0
  367.     beq.s    mt_setspeed
  368.     rts
  369.  
  370. mt_posjmp:
  371.     not.w    mt_status
  372.     moveq    #0,d0
  373.     move.b    3(a6),d0
  374.     subq.b    #1,d0
  375.     move.l    d0,mt_partnrplay
  376.     rts
  377.  
  378. mt_setvol:
  379.     move.b    3(a6),8(a5)
  380.     rts
  381.  
  382. mt_break:
  383.     not.w    mt_status
  384.     rts
  385.  
  386. mt_setfil:
  387.     moveq    #0,d0
  388.     move.b    3(a6),d0
  389.     and.b    #1,d0
  390.     rol.b    #1,d0
  391.     and.b    #$fd,$bfe001
  392.     or.b    d0,$bfe001
  393.     rts
  394.  
  395. mt_setspeed:
  396.     move.b    3(a6),d0
  397.     and.b    #$0f,d0
  398.     beq.s    mt_back
  399.     clr.w    mt_counter
  400.     move.b    d0,mt_cool+3
  401. mt_back:
  402.     rts
  403.  
  404. mt_aud1temp:
  405.     dcb.w    10,0
  406.     dc.w    1
  407.     dcb.w    2,0
  408. mt_aud2temp:
  409.     dcb.w    10,0
  410.     dc.w    2
  411.     dcb.w    2,0
  412. mt_aud3temp:
  413.     dcb.w    10,0
  414.     dc.w    4
  415.     dcb.w    2,0
  416. mt_aud4temp:
  417.     dcb.w    10,0
  418.     dc.w    8
  419.     dcb.w    2,0
  420.  
  421. mt_partnote:    dc.l    0
  422. mt_partnrplay:    dc.l    0
  423. mt_counter:    dc.w    0
  424. mt_partpoint:    dc.l    0
  425. mt_samples:    dc.l    0
  426. mt_sample1:    dcb.l    31,0
  427. mt_maxpart:    dc.w    0
  428. mt_dmacon:    dc.w    0
  429. mt_status:    dc.w    0
  430.  
  431. mt_arpeggio:
  432.     dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c
  433.     dc.w $023a,$021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d
  434.     dc.w $0168,$0153,$0140,$012e,$011d,$010d,$00fe,$00f0
  435.     dc.w $00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097
  436.     dc.w $008f,$0087,$007f,$0078,$0071,$0000,$0000,$0000
  437.  
  438.  
  439. notetable:
  440.     dc.w    856,808,762,720,678,640,604,570
  441.     dc.w    538,508,480,453,428,404,381,360
  442.     dc.w    339,320,302,285,269,254,240,226  
  443.     dc.w    214,202,190,180,170,160,151,143
  444.     dc.w    135,127,120,113,000
  445.  
  446.  
  447.